# -*- conding:UTF-8 -*-

'''
@ Project: P8_02_LumenIM-flask
@ File: user_app.py
@ Author: 罗婷
@ Date：2022/7/11 15:22

'''


import json

import redis
from flask import Blueprint, jsonify, g
from flask_restful import Api, Resource, reqparse, marshal

from common.celery.tasks import send_sms
from common.model_fields.user_fs import user_fieklds
from common.models import db
from common.models.users import Users, Friends
from common.utils.login_auth import login_requir

user_bp = Blueprint('user_bp', __name__, url_prefix='/api/v1/users')
api = Api(user_bp)

# 获取用户信息
class UserInfo(Resource):
    @login_requir
    def get(self):
        uid = g.uid
        friend = Users.query.filter_by(id=uid).first()
        if friend:  # 能查到好友
            friend_data = marshal(friend, user_fieklds)
            return jsonify(message='查询成功', code=200, data=friend_data)
        else:
            return jsonify(message='该用户不存在', code=400)

# 修改用户信息
class ChangeUserInfo(Resource):
    def post(self):
        ...


# 获取用户信息
api.add_resource(UserInfo, '/detail')
# 修改用户信息
api.add_resource(ChangeUserInfo, '/change/detail')


# 上传头像裁剪图片服务接口   post('/api/v1/upload/avatar', data
# api.add_resource(UserInfo, '/change/detail')
#



